package com.wolf.etl.enumeration;

import com.wolf.provider.order.enumerate.QUERY_TYPE;
import com.wolf.util.StringUtils;

/**
 * @author sdyang
 * @create 2019-04-04 11:56
 **/
public enum SQL_FORMULA {

    EQUAL("="),
    NOT_EQUAL("<>"),
    GT(">"),
    GT_EQUAL(">="),
    LT("<"),
    LT_EQUAL("<="),
    LIKE("LIKE"),
    NOT_LIKE("NOT_LIKE"),
    IN("IN"),
    NOT_IN("NOT_IN"),
    IS_NULL("IS_NULL"),
    IS_NOT_NULL("IS_NOT_NULL"),
    BETWEEN("BETWEEN");

    private String type;

    private String className;

    SQL_FORMULA(String type) {
        this.type = type;
    }

    public static SQL_FORMULA get(String type) {
        switch (type) {
            case "=":
                return EQUAL;
            case "<>":
                return NOT_EQUAL;
            case ">":
                return GT;
            case ">=":
                return GT_EQUAL;
            case "<":
                return LT;
            case "<=":
                return LT_EQUAL;
            case "LIKE":
                return LIKE;
            case "NOT_LIKE":
                return NOT_LIKE;
            case "IN":
                return IN;
            case "NOT_IN":
                return NOT_IN;
            case "IS_NULL":
                return IS_NULL;
            case "IS_NOT_NULL":
                return IS_NOT_NULL;
            case "BETWEEN":
                return BETWEEN;
            default:
                return null;
        }
    }

    public boolean isEquals(String type) {
        if (StringUtils.isEmpty(type)) {
            return false;
        }
        for (QUERY_TYPE primaryType : QUERY_TYPE.values()) {
            if (primaryType.getType().equalsIgnoreCase(type)) {
                return true;
            }
        }
        return false;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getClassName() {
        return className;
    }

    public void setClassName(String className) {
        this.className = className;
    }
}
